﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

using Weazel.NativeMath;

using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace Weazel.NativeMath.Test
{
	[TestClass]
	public class TestSignedSubtraction
	{
		/**************************************************************************
		 * Addition (width(result) = longest(a.width, b.widht) + 1
		 **************************************************************************/
		[TestMethod]
		public void TestSignedSubtraction_1()
		{
			Integer a = new Integer(8, 0, true);
			Integer b = new Integer(8, 0, true);
			Assert.AreEqual("0", (a - b).ToDecimalString());
		}

		[TestMethod]
		public void TestSignedSubtraction_2()
		{
			Integer a = new Integer(8, 1, true);
			Integer b = new Integer(8, 0, true);
			Assert.AreEqual("1", (a - b).ToDecimalString());
		}

		[TestMethod]
		public void TestSignedSubtraction_3()
		{
			Integer a = new Integer(8, 10, true);
			Integer b = new Integer(8, 100, true);
			Assert.AreEqual("-90", (a - b).ToDecimalString());
		}

		[TestMethod]
		public void TestSignedSubtraction_4()
		{
			Integer a = new Integer(8, -1, true);
			Integer b = new Integer(8, 0, true);
			Assert.AreEqual("-1", (a - b).ToDecimalString());
		}

		[TestMethod]
		public void TestSignedSubtraction_5()
		{
			Integer a = new Integer(8, -100, true);
			Integer b = new Integer(8, -10, true);
			Assert.AreEqual("-90", (a - b).ToDecimalString());
		}

		[TestMethod]
		public void TestSignedSubtraction_6()
		{
			Integer a = new Integer(32, "0xFFFFFFFF", true);
			Integer b = new Integer(2, 1, true);
			Assert.AreEqual("-2", (a - b).ToDecimalString());
		}

		[TestMethod]
		public void TestSignedSubtraction_7()
		{
			Integer a = new Integer(32, "0x7FFFFFFF", true);
			Integer b = new Integer(8, 0xF, true);
			Assert.AreEqual("7ffffff0", (a - b).ToHexadecimalString());
		}

		[TestMethod]
		public void TestSignedSubtraction_8()
		{
			Integer a = new Integer(96, "0xFFFFFFFFFFFFFFFFFFFFFFFF", true);
			Integer b = new Integer(8, -12, true);
			Assert.AreEqual("11", (a - b).ToDecimalString());
		}
	}
}
